<?php

    include 'classes/db.class.php';

    /*** a new crud object ***/
    $crud = new db();

    /*** The DSN ***/
    $crud->dsn = "mysql:dbname=login;host=localhost";

    /*** MySQL username and password ***/
    $crud->username = 'orsino';
    $crud->password = 'szapo123';


    /*** array of values to insert ***/
    $values = array(
            array('username'=>'baniol')
            );
    /*** insert the array of values ***/
    $crud->dbInsert('tbl_users', $values);

    /*** select all records from table ***/
    $records = $crud->rawSelect('SELECT * FROM animals');

    /*** fetch only associative array of values ***/
    $rows = $records->fetchAll(PDO::FETCH_ASSOC);

    /*** display the records ***/
    foreach($rows as $row)
    {
        foreach($row as $fieldname=>$value)
        {
            echo $fieldname.' = '.$value.'<br />';
        }
        echo '<hr />';
    }

    /*** update the kiwi ***/
    $crud->dbUpdate('animals', 'animal_name', 'troy', 'animal_id', 3);

    /*** delete the second record ***/
    $res = $crud->dbSelect('animals', 'animal_id', 3 );

    /*** show the results ***/
    foreach($res as $row)
    {
        echo $row['animal_name'].' = '.$row['animal_type'].'<br />';
    }
?>